<!--
 * @Author: 小羊今晚不睡觉 2226764294@qq.com
 * @Date: 2025-09-25 13:17:42
 * @LastEditors: 小羊今晚不睡觉 2226764294@qq.com
 * @LastEditTime: 2025-10-09 15:59:38
 * @FilePath: \yougongxia-backstage\src\views\dashboard\console\components\VisitAmount.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div ref="chartRef" :style="{ height, width }"></div>
</template>
<script lang="ts" setup>
import { onMounted, ref, Ref } from 'vue';
import { useECharts } from '@/hooks/web/useECharts';
import { basicProps } from './props';

const {
  width,
  height,
  jobTotalBar
} = defineProps({
  ...basicProps,
});

const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);

onMounted(() => {
  setOptions({
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        lineStyle: {
          width: 1,
          color: '#019680',
        },
      },
    },
    grid: { left: '1%', right: '1%', top: '2  %', bottom: 0, containLabel: true },
    xAxis: {
      type: 'category',
      data: jobTotalBar.categories
    },
    yAxis: {
      type: 'value',
      max: jobTotalBar.yAxis,
      splitNumber: 4,
    },
    series: [
      {
        data: jobTotalBar.series[0]?.data || [],
        type: 'bar',
        barMaxWidth: 80,
        itemStyle: {
          color: '#DCDCDC',
        },
      },
      {
        data: jobTotalBar.series[1]?.data || [],
        type: 'bar',
        barMaxWidth: 80,
        itemStyle: {
          color: '#F36C70',
        },
      },
    ],
  });
});
</script>
